﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Net.Fan.SmallPig.Common;

namespace GeneratePK
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }

        private void buttonGetPK_Click(object sender, RoutedEventArgs e)
        {
            string machineId = textBoxFC.Text.Trim();

            string s1 = machineId.Substring(0, machineId.Length / 2);
            string s2 = machineId.Substring(machineId.Length / 2);
            string tmp = s2 + "fdp" + s1 + "fdy";
            string sha1 = StringUtils.SHA1(tmp);
            StringBuilder pk = new StringBuilder();
            for (int i = 0; i < sha1.Length; i = i + 2)
            {
                pk.Append(sha1[i]);
            }

            textBoxPK.Text = pk.ToString();

        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {

        }
    }
}
